<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="..\node_modules\vue\dist\vue.js"></script>
    <style type="text/css">
        .ld {
            margin-left: 50px;
        }
    </style>
    <script type="text/x-template" id="sync">
        <div v-on:click="click">sync component</div>
    </script>
</head>
<body>
<div id="app">
    <sync></sync>
    <async></async>
</div>
<hr/>

</body>
<script type="application/javascript">
    var sync = Vue.component(
        'sync',
        {
            template: '#sync',
            methods:{
                "click":function (){
                    console.log(this);
                }
            }
        }
    );

    var async = Vue.component(
        'async',
        function(resolve, reject){
            setTimeout(function () {
                if(app_data.inputData % 2 == 0){
                    resolve({
                        template: '<div>async component</div>'
                    });
                }
                else{
                    reject("sth wrong : " + app_data.inputData);
                }
            }, 1000);
        }
    );

    var app_data = {
        "inputData":new Date().getSeconds()
    };

    var app = new Vue({
        el: '#app',
        data: app_data,
    });

</script>
</html>